#ifndef SINGLETON_H
#define SINGLETON_H

#include <iostream>
using namespace std;

class singleton
{
private:
    static singleton *sing;
    singleton(){

    }
    // 防止拷贝构造和赋值操作
public:
    singleton(const singleton &obj){
        ;
    }
    singleton& operator=(const singleton &obj){

    }
public:
    static singleton *getInstance(){
        //lock.begin
        if(sing!=NULL){
            sing=new singleton;
        }
        //lock.end
        return sing;
    }
};
//初始化
singleton* singleton::sing=NULL;

#endif // SINGLETON_H
